package com.wuliu.driver.controller;

import com.wuliu.driver.pojo.Drive;
import com.wuliu.driver.service.DriveService;
import com.wuliu.driver.util.Code;
import com.wuliu.driver.util.Result;
import com.wuliu.driver.util.UploadImg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/drive")
public class DriveController {
    @Autowired
    private UploadImg uploadImg;
    @Autowired
    private DriveService driveService;
    //提交驾驶证照片
    @PostMapping("/upload")
    public Result idCard(MultipartFile file) throws IOException {
        String upload = uploadImg.upload(file);
        return new Result(Code.GET_OK,upload,"上传成功");
    }

    //提交审核
    @PostMapping("/ins")
    public Result ins(@RequestBody Drive drive) {
        return driveService.ins(drive);
    }
}
